package com.newjiabo.applet.controller;

import com.newjiabo.applet.modules.service.AppletHomeService;
import com.newjiabo.common.core.domain.AjaxResult;
import com.newjiabo.common.utils.SecurityUtils;
import com.newjiabo.ski.domain.SkiSnowField;
import com.newjiabo.ski.domain.vo.MemberInfoVo;
import com.newjiabo.ski.service.ISkiSnowFieldInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * {首页接口}
 *
 * @author CaoMengHui.
 * @version 1.0
 * @since 2023/9/23 15:20
 */
@RestController
@RequestMapping("/applet/home")
@Api(tags = "小程序-首页接口")
public class HomeController {
    @Resource
    private ISkiSnowFieldInfoService snowFieldInfoService;
    @Resource
    private AppletHomeService homeService;

    @GetMapping("/getSnowFieldByPosition")
    @ApiOperation(value = "根据当前位置获取雪场信息")
    public AjaxResult getSnowFieldByPosition() {
        SkiSnowField skiSnowField = snowFieldInfoService.selectSkiSnowFieldById("1704325700351234048");
        return AjaxResult.success(skiSnowField);
    }

    @ApiOperation(value = "获取当前小程序用户信息(包括是否注册证明)")
    @GetMapping("/getMemberInfo/{snowFieldId}")
    public AjaxResult getMemberInfo(@PathVariable String snowFieldId){
        String memberId = SecurityUtils.getLoginUser().getMemberId();
        MemberInfoVo memberInfoVo = homeService.getMemberInfo(memberId,snowFieldId);
        return AjaxResult.success(memberInfoVo);
    }
}